package javasec.seed.seeds;



import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

import javasec.seed.*;


public class TeamSeed extends Seed
{
	public TeamSeed() throws RemoteException
	{
		System.out.println("TeamSeed: loading");

		try
		{
		
		// make sure the tables are in place
		SeedServer.dataSeed.createTable("TARGET",new String[]
		{
			"TARGET varchar(32) not null",
			"STATUS varchar(32)",
			"NOTES varchar(1024)"
		});

		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	}

	@Exposed(description="send a message to the team", arguments={"message"})
	public String sendMessage(String message)
	{
		ManagerSeed.notifyClients(new SeedNotification("incomingMessage",message));
		return null;
	}

	@Exposed(description="add a target", arguments={"target"})
	public String addTarget(String target) throws RemoteException
	{
		SeedServer.dataSeed.insertRow("TARGET",new Object[]{target,"new",""});
		return null;
	}

	@Exposed(description="set status", arguments={"target","status"})
	public String setStatus(Integer targetID, String status) throws RemoteException
	{
		if(status==null)return null;
		SeedServer.dataSeed.updateField("TARGET",targetID,"STATUS",status);
		return null;
	}
	
	@Exposed(description="set note", arguments={"target","note"})
	public String setNote(Integer targetID, String note) throws RemoteException
	{
		if(note==null)return null;
		SeedServer.dataSeed.updateField("TARGET",targetID,"NOTES",note);
		return null;
	}
}

